package com.java2207.group1.controller;

import com.java2207.group1.common.LayuiPageVo;
import com.java2207.group1.common.R;
import com.java2207.group1.pojo.Department;
import com.java2207.group1.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;


    @RequestMapping("/departmentList")
    public LayuiPageVo<Department> selectList(){
        departmentService.updateDeparmentNum();
        return departmentService.selectList();
    }

    @RequestMapping("/selectDepartment")
    public R selectDepartment(){
        List<Department> list = departmentService.selectDepartment();
        if (list != null){
            return R.ok().data("list",list);
        }else {
            return R.error();
        }
    }
}
